package logic

import (
	"context"
	"gorm.io/gorm"
	"local-life/models/mysql"

	"local-life/liferpc/internal/svc"
	"local-life/liferpc/liferpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShopListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShopListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShopListLogic {
	return &ShopListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShopListLogic) ShopList(in *liferpc.ShopListRequest) (*liferpc.ShopListResponse, error) {
	// todo: add your logic here and delete this line
	shop := mysql.Shop{
		Model: gorm.Model{ID: uint(in.ShopId)},
	}
	mysql.DB.Debug().Find(&shop)

	return &liferpc.ShopListResponse{
		ShopName: shop.ShopName,
		Address:  shop.Address,
		Phone:    shop.Phone,
		State:    shop.State,
		Price:    float32(shop.Price),
		Image:    shop.Image,
	}, nil
}
